package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import entity.Pet;
import service.PetService;
import service.Impl.PetServiceImpl;

/**
 * Servlet implementation class ExitsSetvlet
 */
public class ExitsSetvlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		int breed=Integer.parseInt(request.getParameter("breed"));
		PetService pet=new PetServiceImpl();
		List<Pet> list=pet.findPetBreed(breed);
		String data=JSON.toJSONString(list);
		PrintWriter out=response.getWriter();
		out.print(data);
		out.close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
